package com.mlethe.library.multi.api.entity;

import android.graphics.Bitmap;

import androidx.annotation.DrawableRes;

/**
 * 图片对象
 */
public final class ImageObject {
    /**
     * 图片地址（http开头的为URL地址）
     */
    private String imagePath;
    /**
     * 图片二进制流
     */
    private byte[] imageData;
    /**
     * 图片
     */
    private Bitmap bitmap;
    /**
     * 图片资源id
     */
    @DrawableRes
    private int drawableId;

    public ImageObject(String imagePath) {
        this.imagePath = imagePath;
    }

    public ImageObject(byte[] imageData) {
        this.imageData = imageData;
    }

    public ImageObject(Bitmap bitmap) {
        this.bitmap = bitmap;
    }

    public ImageObject(int drawableId) {
        this.drawableId = drawableId;
    }

    /**
     * 获取图片地址
     */
    public String getImagePath() {
        return imagePath;
    }

    /**
     * 获取图片二进制数组
     */
    public byte[] getImageData() {
        return imageData;
    }

    /**
     * 获取图片
     */
    public Bitmap getBitmap() {
        return bitmap;
    }

    /**
     * 图片资源id
     */
    public int getDrawableId() {
        return drawableId;
    }

    /**
     * 释放内存
     */
    public void release() {
        imagePath = null;
        imageData = null;
        bitmap = null;
        drawableId = 0;
    }
}
